#define _CRT_SECURE_NO_WARNINGS 1

class Solution
{
public:
    int jewelleryValue(vector<vector<int>>& f)
    {
        int n = f.size();
        int m = f[0].size();//

        vector<vector<int>> dp(n + 1, vector<int>(m + 1));

        for (int i = 1; i <= n; i++)
        {
            for (int j = 1; j <= m; j++)
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + f[i - 1][j - 1];
        }

        return dp[n][m];
    }
};